/*
  Copyright (C) 2009, Erik Eliasson
  
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

/*
 * Authors: Erik Eliasson <ere@kth.se>
*/


#include<config.h>

#include<libmutil/mtime.h>

#include<libmutil/stringutils.h>

using namespace std;

uint64_t startTime=0;

LIBMUTIL_API std::string nowStr(){
        if (startTime==0)
                startTime = mtime();
        uint64_t t;
        t=mtime();
        int64_t sec = t / 1000 - startTime / 1000;
        int64_t msec = t - startTime;
        msec = msec%1000;

        string header = (sec<100?string("0"):string("")) +
                (sec<10?"0":"") +
                itoa((int)sec)+
                ":"+
                (msec<10?"0":"")+
                (msec<100?"0":"")+
                itoa((int)msec);

	return header;

}

